#!/bin/bash

rootDir="/usr/local/sshm"
confDir="/usr/local/sshm/conf"
declare -a hostMap
declare -a showMap
num=1

files=$(ls $confDir | grep .conf)
for filename in $files
do
    showMap[$num]=$filename
    let num+=1
done

# show menu
for key in ${!showMap[@]}
do
    echo  "    "$key")  "${showMap[$key]}
done
echo "    > input your choose key....."

function parseConf(){
    let cnum=1
    while read myline
    do
    #echo "LINE:"$myline
    scanKey=${myline%:*}
    scanValue=${myline#*:}
    hostMap[$cnum]=$scanValue
    let cnum+=1
    done < "${confDir}/$1"
}

# std read
read showKey

parseConf ${showMap[$showKey]}
$rootDir/runexp.sh ${hostMap[1]} ${hostMap[2]} ${hostMap[3]} ${hostMap[4]}